package org.example;

public class Cook extends Thread{

    @Override
    public void run(){
        //判断是否有汉堡，有就等待，没有生产
        //把汉堡放桌子上
        //叫醒等待的消费者开吃
        while (true){
            synchronized (Desk.lock){
                if (Desk.count == 0){
                    break;
                }else {
                    if (Desk.count == 0){
                        break;
                    }else {
                        if (!Desk.flag){
                            //生产
                            System.out.println("生产汉堡");
                            Desk.flag = true;
                            Desk.lock.notify();
                        }else {
                            try {
                                Desk.lock.wait();
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }
        }
    }
}
